﻿using System;
using System.Windows;
using System.Windows.Controls;
using bitMail.Class;

namespace bitMail.Forms
{
    public partial class Dziennik : Window
    {
        readonly SqliteHelper _sqliLiteHelper;
        
        public Dziennik()
        {
            InitializeComponent();
            _sqliLiteHelper = new SqliteHelper();
            FillTemplateGrid(DateTime.Now);
        }

        void FillTemplateGrid(DateTime date)
        {
            var r = _sqliLiteHelper.GetDailyEntries(date);
            DziennikGrid.ItemsSource = r;
        }

        private void Calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
        {
            var calendar = sender as Calendar;
            if (calendar == null || !calendar.SelectedDate.HasValue) return;
            var date = calendar.SelectedDate.Value;
            FillTemplateGrid(date);
        }
    }
}
